package com.example.zx.theline.lyjh.pub;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.zx.theline.R;
import com.loopj.android.http.RequestParams;

import org.apache.http.Header;
import org.w3c.dom.Text;

import java.util.HashMap;
import java.util.Map;

import GsonBean.JhshLsBean;
import Utils.MyToast;
import app.MyApplication;
import base.BaseActivity;
import network.NetWorkApi;
import network.ObjectHttpResponseHandler;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * 审核记录查看历史详情
 */
public class JhshHistoryActivity extends BaseActivity implements View.OnClickListener {
    private JhshLsBean jhshXqBean;
    //标题
    private TextView centerTextView;
    private TextView rightTextView, leftTextView,cancel;
    //计划内容
    private TextView tv_hb, lb, yf, ydbh, rqsj, kssj, jssj, xm, dd, hb, lc, xmmc, sgnr, sgjx, blfh;
    // 相关单位
    private TextView sgdw, sgdwfzr, jldw, jldwfzr, jsdw, cwzd, sbgldw, qtdw, shcs, xmzgbm,tjsj,nbshsj;
    private LinearLayout layout_blfh;
    public static GsonBean.ShyjhxqBean ZsyjhxxShBean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jhsh_history);
        InitView();
        InitData();
        InitListen();
    }

    @Override
    protected void InitView() {
        centerTextView = (TextView) findViewById(R.id.centerTextView);
        centerTextView.setText("历史详情");
        leftTextView = (TextView) findViewById(R.id.leftTextView);
        rightTextView = (TextView) findViewById(R.id.rightTextView);
        cancel = (TextView) findViewById(R.id.cancel);
        rightTextView.setVisibility(View.GONE);

        lb = (TextView) findViewById(R.id.lb);
        tv_hb = (TextView) findViewById(R.id.tv_hb);
        yf = (TextView) findViewById(R.id.yf);
        ydbh = (TextView) findViewById(R.id.ydbh);
        rqsj = (TextView) findViewById(R.id.rqsj);
        kssj = (TextView) findViewById(R.id.kssj);
        jssj = (TextView) findViewById(R.id.jssj);
        xm = (TextView) findViewById(R.id.xm);
        dd = (TextView) findViewById(R.id.dd);
        hb = (TextView) findViewById(R.id.hb);
        lc = (TextView) findViewById(R.id.lc);
        xmmc = (TextView) findViewById(R.id.xmmc);
        sgnr = (TextView) findViewById(R.id.sgnr);
        sgjx = (TextView) findViewById(R.id.sgjx);
        blfh = (TextView) findViewById(R.id.blfh);
        layout_blfh = (LinearLayout) findViewById(R.id.layout_blfh);

        sgdw = (TextView) findViewById(R.id.sgdw);
        sgdwfzr = (TextView) findViewById(R.id.sgdwfzr);
        jldw = (TextView) findViewById(R.id.jldw);
        jldwfzr = (TextView) findViewById(R.id.jldwfzr);
        jsdw = (TextView) findViewById(R.id.jsdw);
        cwzd = (TextView) findViewById(R.id.cwzd);
        sbgldw = (TextView) findViewById(R.id.sbgldw);
        qtdw = (TextView) findViewById(R.id.qtdw);
        shcs = (TextView) findViewById(R.id.shcs);
        xmzgbm = (TextView) findViewById(R.id.xmzgbm);
        tjsj = (TextView) findViewById(R.id.tjsj);
        nbshsj = (TextView) findViewById(R.id.nbshsj);

    }

    @Override
    protected void InitData() {

        Map<String,String> map=new HashMap<>();
        map.put("bh", ZsyjhxxShBean.getInfo().getBh());
//        MyApplication.ShowWaitDialog(getContext());
        NetWorkApi.getJhshLsXq(map, new Callback<JhshLsBean>() {
                    @Override
                    public void onResponse(Call<JhshLsBean> call, Response<JhshLsBean> response) {
                        try {
                            jhshXqBean = response.body();
                            if (jhshXqBean.getMsg().equals("success")) {
                                if (jhshXqBean.getXlxbList().size() != 0) {
                                    lb.setText(jhshXqBean.getInfo().getLb());
                                    tv_hb.setText(jhshXqBean.getInfo().getBh());
                                    yf.setText(jhshXqBean.getInfo().getSgny());
                                    ydbh.setText(jhshXqBean.getInfo().getBh());
                                    rqsj.setText(jhshXqBean.getInfo().getSgrq());

                                    xm.setText(jhshXqBean.getXlxbList().get(0).getXlmc());
                                    lc.setText(jhshXqBean.getXlxbList().get(0).getLic());
                                    hb.setText(jhshXqBean.getXlxbList().get(0).getXbmc());
                                    dd.setText(jhshXqBean.getXlxbList().get(0).getSgdd());
                                    xmmc.setText(jhshXqBean.getInfo().getSgxmmc());
                                    sgnr.setText(jhshXqBean.getInfo().getSgnr());
                                    sgjx.setText(jhshXqBean.getInfo().getSgjx());
                                    blfh.setText(jhshXqBean.getInfo().getBlfhcs());


                                    sgdw.setText(jhshXqBean.getInfo().getSgdwmc());
                                    sgdwfzr.setText(jhshXqBean.getInfo().getSgdwfzr());
                                    jldw.setText(jhshXqBean.getInfo().getJldwmc());
                                    jldwfzr.setText(jhshXqBean.getInfo().getJldwfzr());
                                    jsdw.setText(jhshXqBean.getInfo().getJsdwmc());
                                    cwzd.setText(jhshXqBean.getInfo().getCwzdmc());
                                    sbgldw.setText(jhshXqBean.getInfo().getSbgldw());
                                    qtdw.setText(jhshXqBean.getInfo().getQtdw());
                                    shcs.setText(jhshXqBean.getInfo().getShcs());
                                    xmzgbm.setText(jhshXqBean.getInfo().getSpcs());
                                    tjsj.setText(jhshXqBean.getInfo().getYdtirq());
                                    nbshsj.setText(jhshXqBean.getInfo().getNbtjrq());
                                    if (lb.getText().equals("B")) {
                                        layout_blfh.setVisibility(View.VISIBLE);
                                    } else {
                                        layout_blfh.setVisibility(View.GONE);
                                    }
                                } else {
                                    MyApplication.ShowWaitDialog(JhshHistoryActivity.this);
                                    MyApplication.setWaitDialogMsg("暂无数据");
                                }
                            } else {
                                MyApplication.ShowWaitDialog(JhshHistoryActivity.this);
                                MyApplication.setWaitDialogMsg("数据错误");
                            }
                        } catch (Exception e) {
                            MyToast.showFail();
                        }
                        MyApplication.HideWaitDialog();
                    }

                    @Override
                    public void onFailure(Call<JhshLsBean> call, Throwable t) {
                        MyToast.showFail();
                    }
                }

        );
    }

    @Override
    protected void InitListen() {
        leftTextView.setOnClickListener(this);
        cancel.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.leftTextView:
                finish();
                break;
            case R.id.cancel:
                finish();
                break;
            default:
                break;
        }
    }
}
